<template>
	<view class="more_data dis_f_co_c_c">
		<template v-if="list.length">
			<template v-if="more">
				<view class="dis_f_c_c">
					<image class="icon" :src="$.img_src+'/components/more-data/loading.png'" mode="aspectFit"></image>
					<text>加载中...</text>
				</view>
			</template>
			<template v-else>
				<image class="no_more" :src="$.img_src+'/components/more-data/no_more.png'" mode="aspectFit"></image>
			</template>
		</template>
		<template v-else>
			<template v-if="more">
				<view class="dis_f_c_c">
					<image class="icon" :src="$.img_src+'/components/more-data/loading.png'" mode="aspectFit"></image>
					<text>加载中...</text>
				</view>
			</template>
			<template v-else>
				<slot></slot>
			</template>
		</template>
	</view>
</template>

<script>
	export default {
		props: {
			// 是否存在数据
			list: {
				type: Array,
				default: null,
			},
			// 是否还有更多数据
			more: {
				type: Boolean,
				default: true,
			},
		},
		data() {
			return {
				// 公用的js
				$: this.$,
			}
		},
		methods: {

		}
	}
</script>

<style lang="scss" scoped>
	.more_data {
		min-height: 90upx;
		font-size: 24upx;
		color: #aaa;

		.icon {
			width: 32upx;
			height: 32upx;
			margin-right: 10upx;

			animation: loading 2s linear infinite;
			-o-animation: loading 2s linear infinite;
			-moz-animation: loading 2s linear infinite;
			-webkit-animation: loading 2s linear infinite;
		}

		// 没有更多数据
		.no_more {
			width: 220rpx;
			height: 30rpx;
		}

		// 没有数据
		.no_data {
			padding-top: 360upx;
			padding-bottom: 200upx;
		}
	}

	@keyframes loading {
		from {
			transform: rotate(0deg)
		}

		to {
			transform: rotate(360deg)
		}
	}

	@-moz-keyframes loading {
		from {
			transform: rotate(0deg)
		}

		to {
			transform: rotate(360deg)
		}
	}

	@-webkit-keyframes loading {
		from {
			transform: rotate(0deg)
		}

		to {
			transform: rotate(360deg)
		}
	}

	@-o-keyframes loading {
		from {
			transform: rotate(0deg)
		}

		to {
			transform: rotate(360deg)
		}
	}
</style>
